package impl.sort;

import anaydis.sort.SorterType;

import java.util.Comparator;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: alumnosfi
 * Date: 17/01/2011
 * Time: 15:30:39
 * To change this template use File | Settings | File Templates.
 */
public class BubbleSorter extends AbstractSorter {
    public BubbleSorter(){
        super(SorterType.BUBBLE);
    }
    public <T> void sort(Comparator<T> c, List<T> list){
        int fin = list.size()-1;
        for(int i=0; i<list.size(); i++){
            for(int j=0; j<fin; j++){
                if(greater(c, list, j, j+1)){
                    swap(list, j, j+1);
                }
            }
            fin--;
        }
    }
}